package com.swf.seed.algorithms.problem;

/**
 * ClassName: Gcdlcm <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: 最大公因数、最小公倍数、因式分解. <br/>
 * 最大公因数、最小公倍数、因式分解<br/>
 * 
 * date: 2015-1-20 下午3:56:06 <br/>
 *
 * @author shenwf10476
 * @version 
 * @since JDK 1.6
 */
public class Gcdlcm {
	public int gcd(int m,int n){
		int r = 0;
		while (n!=0){
			r = m % n;
			m = n;
			n = r;
		}
		return m;
	}
	
	public int lcm(int m,int n){
		return m*n/gcd(m, n);
	}
	public static void main(String[] args) {
		int gcd = new Gcdlcm().gcd(12, 8);
		int lcm = new Gcdlcm().lcm(12, 8);
		System.out.println(gcd);
		System.out.println(lcm);
	}
}
